package org.jwd.storage.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.jwd.core.entity.AuthEntity;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author vizz
 * @since 2022/5/16 17:28
 */
@Mapper
@Repository
public interface AuthMapper extends BaseMapper<AuthEntity> {

    @Select("SELECT *\n" +
            "FROM auth\n")
    List<AuthEntity> getAll();

    @Select("select *\n" +
            "from auth\n" +
            "where deleted = '0'\n" +
            "  and user_id = #{userId}\n" +
            "  and type = '0'\n" +
            "  and TIMESTAMPDIFF(MINUTE, now(), last_login_time) < 30")
    AuthEntity findLoginDisabled(@Param("userId")Long userId);
}
